<template>
	<zh-sheet :margin="[32, 0,32,24]" :padding="[24, 20]" :shadow="2" :round="6">
		<view class="flex-row-center-between" >
			<view style="border-left: 10rpx solid #2f54eb;">
				<zh-text  :fontSize="36" class="text-weight-b pl-10" label="是否报名直升班"></zh-text>
			</view >
			<zh-radio-group v-model="form.zsbFlag" @change="zsbChange">
				<zh-radio  value="1" label="是"></zh-radio>
				<zh-radio :followTheme="false" color="orange" value="0" label="否"></zh-radio>
			</zh-radio-group>
		</view>
		<zh-form-desc v-if="form.zsbFlag==='1'" field="zsbSchoolName"  v-model="form.zsbVO.schoolName" label="报名学校"  :transprent="true"></zh-form-desc>
		<zh-form-desc v-if="form.zsbFlag==='1'" field="zsbConfigTypeName"  v-model="form.zsbVO.configTypeName" label="报名类别"  :transprent="true"></zh-form-desc>
	</zh-sheet>
</template>

<script lang="ts" setup>
	//直升班报名信息
	import {watch,ref} from "vue";
	// ------------------接收传入参数(组件)-------------------
	const props = defineProps({
		modelValue: {
		  type: Object,
		  default: () => {
			return {
				
			}
		  }
		}
	})
	const emits = defineEmits([
	  "update:modelValue",
	]);
	//---------------内部变量--------------------
	const form=ref<any>(props.modelValue)
	
		
	const getSchoolFlag=ref(false)
	//----------------内部方法--------------------
	const zsbChange=(value:String)=>{
		if(value==='1'){
			form.value.privateAppointStudentId=form.value.zsbVO.privateAppointStudentId
			getSchoolInfo(form.value.zsbVO.schoolId)
			form.value.mzgFlag='0'
			form.value.mbFlag='0'
		}else{
			form.value.privateAppointStudentId=''
			
		}
	}
	
	const getSchoolInfo=(schoolId:String)=>{
		if(getSchoolFlag.value||!schoolId){
			return
		}
		getSchoolFlag.value=true
		$api.common.send.post("eduschool0002",{orgId:schoolId}).then((res:any)=>{
			let configTypeDict=res.result.configList||[]
			if(configTypeDict.length>0){
				//剔除直升班报名列表，直升班专门一栏报名
				configTypeDict=configTypeDict.filter((item :any) => {
					return item.zsFlag === '1'
				})
			}				
			if(configTypeDict&&configTypeDict.length>0){
				form.value.zsbVO.configTypeName=configTypeDict[0].configTypeName
			}
		}).catch(() => {
			getSchoolFlag.value=false
		})
	}
	if(props.modelValue.zsbFlag==='1'){
		zsbChange(props.modelValue.zsbFlag)
	}
	watch(
	  () => props.modelValue,
	  () => {
	   form.value=props.modelValue
	   zsbChange(props.modelValue.zsbFlag)
	  },
	  {
	    deep:true
	  }
	  
	)
	
	watch(
		() => form.value,
		() => {
			//父组件发送数据
			emits("update:modelValue", form.value);
		},
		{
			deep: true,
		}
	);
</script>

<style>
</style>